import 'package:flutter_base_app/generated/json/base/json_convert_content.dart';
import 'package:flutter_base_app/model/ota_version_data.dart';

OtaVersionData $OtaVersionDataFromJson(Map<String, dynamic> json) {
  final OtaVersionData otaVersionData = OtaVersionData();
  final String? packageVersionId = jsonConvert.convert<String>(json['packageVersionId']);
  if (packageVersionId != null) {
    otaVersionData.packageVersionId = packageVersionId;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    otaVersionData.title = title;
  }
  final int? icon = jsonConvert.convert<int>(json['icon']);
  if (icon != null) {
    otaVersionData.icon = icon;
  }
  final String? currentVersion = jsonConvert.convert<String>(json['currentVersion']);
  if (currentVersion != null) {
    otaVersionData.currentVersion = currentVersion;
  }
  final int? hasNewVersion = jsonConvert.convert<int>(json['hasNewVersion']);
  if (hasNewVersion != null) {
    otaVersionData.hasNewVersion = hasNewVersion;
  }
  final String? latestVersion = jsonConvert.convert<String>(json['latestVersion']);
  if (latestVersion != null) {
    otaVersionData.latestVersion = latestVersion;
  }
  final String? packageSize = jsonConvert.convert<String>(json['packageSize']);
  if (packageSize != null) {
    otaVersionData.packageSize = packageSize;
  }
  final String? packageUrl = jsonConvert.convert<String>(json['packageUrl']);
  if (packageUrl != null) {
    otaVersionData.packageUrl = packageUrl;
  }
  final String? releaseNote = jsonConvert.convert<String>(json['releaseNote']);
  if (releaseNote != null) {
    otaVersionData.releaseNote = releaseNote;
  }
  final String? packageFileCrc = jsonConvert.convert<String>(json['packageFileCrc']);
  if (packageFileCrc != null) {
    otaVersionData.packageFileCrc = packageFileCrc;
  }
  return otaVersionData;
}

Map<String, dynamic> $OtaVersionDataToJson(OtaVersionData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['packageVersionId'] = entity.packageVersionId;
  data['title'] = entity.title;
  data['icon'] = entity.icon;
  data['currentVersion'] = entity.currentVersion;
  data['hasNewVersion'] = entity.hasNewVersion;
  data['latestVersion'] = entity.latestVersion;
  data['packageSize'] = entity.packageSize;
  data['packageUrl'] = entity.packageUrl;
  data['releaseNote'] = entity.releaseNote;
  data['packageFileCrc'] = entity.packageFileCrc;
  return data;
}

extension OtaVersionDataExtension on OtaVersionData {
  OtaVersionData copyWith({
    String? packageVersionId,
    String? title,
    int? icon,
    String? currentVersion,
    int? hasNewVersion,
    String? latestVersion,
    String? packageSize,
    String? packageUrl,
    String? releaseNote,
    String? packageFileCrc,
  }) {
    return OtaVersionData()
      ..packageVersionId = packageVersionId ?? this.packageVersionId
      ..title = title ?? this.title
      ..icon = icon ?? this.icon
      ..currentVersion = currentVersion ?? this.currentVersion
      ..hasNewVersion = hasNewVersion ?? this.hasNewVersion
      ..latestVersion = latestVersion ?? this.latestVersion
      ..packageSize = packageSize ?? this.packageSize
      ..packageUrl = packageUrl ?? this.packageUrl
      ..releaseNote = releaseNote ?? this.releaseNote
      ..packageFileCrc = packageFileCrc ?? this.packageFileCrc;
  }
}